From f09aa2a7d6057e78e1773d5c345886c858476a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 25 May 2020 13:46:51 +0100 Subject: extract_freestyle: print metadata about messages outside of the message. This makes it easier to figure out what the message length is meant to be. --- reversing_tools/abbott/extract_freestyle.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reversing_tools/abbott/extract_freestyle.py b/reversing_tools/abbott/extract_freestyle.py index b394a6c..e0ae66d 100755 --- a/reversing_tools/abbott/extract_freestyle.py +++ b/reversing_tools/abbott/extract_freestyle.py @@ -8,6 +8,7 @@ import argparse import logging import sys +import textwrap import usbmon import usbmon.chatter @@ -151,6 +152,8 @@ def main(): if message_type == _KEEPALIVE_TYPE and not args.print_keepalive: continue + message_metadata = [] + if args.encrypted_protocol and message_type not in _UNENCRYPTED_TYPES: # When expecting encrypted communication), we ignore the # message_length and we keep it with the whole message. @@ -158,10 +161,19 @@ def main(): message = packet.payload[1:] else: message_length = packet.payload[1] + message_metadata.append(f"LENGTH={message_length}") message_end_idx = 2 + message_length message_type = f" {message_type:02x}" message = packet.payload[2:message_end_idx] + if message_metadata: + metadata_string = "\n".join( + textwrap.wrap( + " ".join(message_metadata), width=80, break_long_words=False + ) + ) + print(metadata_string) + print( usbmon.chatter.dump_bytes( packet.direction, message, prefix=f"[{message_type}]", print_empty=True, -- cgit v1.2.3